<?php
	$query = "select * from `radio_dj` where `userid`='$id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)) {

	//isdj
	//text
		if ($_REQUEST['upd_profile']) {
			$text 		= text2html(escapestr($_REQUEST['text']));
			$name     = escapestr($_REQUEST['name']);
			$query2 	= "update `radio_dj` set `name`= '$name',`text`='$text'  where `userid`='$id'";
			$result2 	=	mysql_query($query2);
			if ($result2) {
				$SITE_MIDDLE .= FormatElement(GetLangString($lang, "txt_saved"),GetLangString($lang, "msg_saved"));
			} else {
				$SITE_MIDDLE .= FormatElement(GetLangString($lang, "txt_error"),GetLangString($lang, "msg_dberror"));
			}
			// 
			$query = "select * from `radio_dj` where `userid`='$id'";
			$result = mysql_query($query);
			//
		}
		$djprofile = mysql_fetch_array($result);
		$text = html2text($djprofile['text']);
		$name = $djprofile['name'];
		$SITE_MIDDLE .= FormatElement ( GetLangString ($lang, "txt_profiletext") , 
		"<form method=\"post\" action=\"/index.php?do=djprofile\">".
		FormatSmallElement ( GetLangString ($lang, 'txt_djname'),
		"<input type=\"text\" value=\"$name\" name=\"name\">").
		FormatSmallElement ( GetLangString ($lang, "txt_djprofile"),
		"<textarea name=\"text\" rows=\"5\">$text</textarea>").
		"<input value=\"".GetLangString($lang,"txt_save")."\" name = \"upd_profile\" 	type=\"submit\"></form>");

	//photo
//---- begin public photos

		if ($_REQUEST['profilepic']) {
			$profilepic	=	escapestr($_REQUEST['profilepic']);	
			$query =  "UPDATE radio_dj set photo=$profilepic where userid=$id"; 
			$result = mysql_query($query);  
			$SITE_MIDDLE .= FormatELement(GetLangString ($lang,"txt_profilepic"),GetLangString ($lang,"msg_profilepicset")); 		

		} 
		
		$query      = "SELECT * from `photos` where `owner`='$id' and `access`='0'";

		$result 		=	 mysql_query($query);
		if (mysql_num_rows($result)) {
			while ($photoinfo = mysql_fetch_assoc($result)){

			$photos =      "<div class=\"userthumb\"><a href=\"/index.php?do=viewphoto&photo_id=".$photoinfo['id']."\">
											<img border=\"0\" src=\"index.php?do=getphoto&square=1&size=100&id=".$photoinfo['id']."\" title=\"".
											$photoinfo['title']."\"></a><br><a href=\"index.php?do=djprofile&profilepic=".$photoinfo['id']."\">".
											GetLangString($lang, "txt_setprofilepic")."</a>

</div>$photos";						}
		$SITE_MIDDLE .= FormatElement ( GetLangString ( $lang, "txt_publicphotoalbum" ) ,  GetLangString ( $lang, "msg_publicphotoalbum" ) . "<br>$photos"); 
		unset($photos);		
		} else {
			$SITE_MIDDLE .= FormatElement ( GetLangString ( $lang, "txt_publicphotoalbum" ) ,  GetLangString ( $lang, "msg_publicphotoalbumempty" ));
		} 
		




	} else {
		$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_error"),GetLangString($lang,"msg_nodjerror"));
	} 

 

?>
